﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace BitcoinMarket.Libs
{
    public class ColorTools
    {
        public static Color GetColorFromHexa(string hexaColor)
        {
            if (hexaColor.Length == 7)
            {
                return Color.FromArgb(
                    Convert.ToByte("FF", 16),
                    Convert.ToByte(hexaColor.Substring(1, 2), 16),
                    Convert.ToByte(hexaColor.Substring(3, 2), 16),
                    Convert.ToByte(hexaColor.Substring(5, 2), 16)
                );
            }
            else if (hexaColor.Length == 9)
            {
                return Color.FromArgb(
                    Convert.ToByte(hexaColor.Substring(1, 2), 16),
                    Convert.ToByte(hexaColor.Substring(3, 2), 16),
                    Convert.ToByte(hexaColor.Substring(5, 2), 16),
                    Convert.ToByte(hexaColor.Substring(7, 2), 16)
                );
            }
            else
            {
                return Colors.Black;
            }
        }
    }
}
